import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '产品名称',
    align:"center",
    dataIndex: 'goodsName'
   },
   {
    title: '产品条码',
    align:"center",
    dataIndex: 'goodsNo'
   },
   {
    title: '生产日期',
    align:"center",
    dataIndex: 'manufactureDate',
    customRender:({text}) =>{
      text = !text ? "" : (text.length > 10 ? text.substr(0,10) : text);
      return text;
    },
   },
   {
    title: '创建日期',
    align:"center",
    dataIndex: 'createTime',
    sorter: true,
   },
   {
    title: '图片',
    align:"center",
    dataIndex: 'noteImage',
    customRender:render.renderImage,
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "产品名称",
      field: 'goodsName',
       component: 'Input',
      componentProps:{
         dict:"goods_info,goods_name,goods_name"
      },
      //colProps: {span: 6},
 	},
	{
      label: "产品条码",
      field: 'goodsNo',
      component: 'Input',
      //colProps: {span: 6},
 	},
	{
      label: "生产日期",
      field: 'manufactureDate',
      component: 'DatePicker',
      componentProps: {
        valueFormat: 'YYYY-MM-DD'
      },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '产品名称',
    field: 'goodsName',
    component: 'Input',
    componentProps:{
       dict:"goods_info,goods_name,goods_name",
       returnFields: ['goods_no'], // 告诉组件还要返回 goods_no
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入产品名称!'},
          ];
     },
  },
  {
    label: '产品条码',
    field: 'goodsNo',
    component: 'Input',
  },
  {
    label: '生产日期',
    field: 'manufactureDate',
    component: 'DatePicker',
    componentProps: {
      valueFormat: 'YYYY-MM-DD'
    },
  },
  {
    label: '图片',
    field: 'noteImage',
     component: 'JImageUpload',
     componentProps:{
        fileMax: 0
      },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  goodsName: {title: '产品名称',order: 0,view: 'sel_search', type: 'string',dictTable: "goods_info", dictCode: 'goods_name', dictText: 'goods_name',},
  goodsNo: {title: '产品条码',order: 1,view: 'text', type: 'string',},
  manufactureDate: {title: '生产日期',order: 2,view: 'date', type: 'string',},
  noteImage: {title: '图片',order: 3,view: 'image', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}